<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>后台管理</title>
		<!-- Bootstrap core CSS -->
		<link th:href="@{/webjars/bootstrap/4.4.1-1/css/bootstrap.css}" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
		<link th:href="@{/iconfont/iconfont.css}" rel="stylesheet">
		<link href="asserts/css/from-table.css" th:href="@{/asserts/css/from-table.css}" rel="stylesheet">
		<style type="text/css">
			
			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}

			.info{
				float: left;
			}
			.pagination{
				float:right;
			}
		</style>
	</head>

	<body>
		<!--引入抽取的topbar-->
		<!--模板名：会使用thymeleaf的前后缀配置规则进行解析-->
		<div th:replace="commons/bar::topbar"></div>

		<div class="container-fluid">
			<div class="row">
				<!--引入侧边栏-->
				<div th:replace="commons/bar::#sidebar(activeUri='trains')"></div>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<form class="navbar-form navbar-right search-range-three" th:action="@{/trasearch}">
						<div class="input-group mb-3">
							<input name="name" type="text" class="form-control info-box" placeholder="名字" th:value="${name}">
							<input name="TWorkId" type="text" class="form-control info-box" placeholder="工号：ce10****" th:value="${TWorkId}">
							<select class="form-control info-box" name="deptname">
								<option value="">--请选择--</option>
								<option th:selected="${deptname} eq '行政部'" >行政部</option>
								<option th:selected="${deptname} eq '财务部'" >财务部</option>
								<option th:selected="${deptname} eq '质量管理部'" >质量管理部</option>
								<option th:selected="${deptname} eq '营销部'" >营销部</option>
								<option th:selected="${deptname} eq '运营部'" >运营部</option>
								<option th:selected="${deptname} eq '研发部'" >研发部</option>
								<option th:selected="${deptname} eq '运维部'" >运维部</option>
								<option th:selected="${deptname} eq '人事部'" >人事部</option>
								<!--<option th:selected="${deptname}" th:each="department:${depts}"  th:text="${department.name}"></option>-->
							</select>
							<div class="input-group-append" >
								<button class="btn btn-success query" type="submit">
									<span class="iconfont icon&#45;&#45;search1"></span>
								</button>
							</div>
						</div>

					</form>
					<h2 class="add"><a class="btn btn-sm btn-success" href="train" th:href="@{/train}">添加</a></h2>
					<div class="table-responsive">
						<table class="table table-striped table-sm table-bordered">
							<thead>
								<tr>
									<th>编号</th>
									<th>员工编号</th>
									<th>员工姓名</th>
									<th>培训部门</th>
									<th>培训开始日期</th>
									<th>培训结束日期</th>
									<th>培训内容</th>
									<th>备注</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<tr th:each="train:${pageInfo.list}">
									<td>[[${train.TId}]]</td>
									<td>[[${train.TWorkId}]]</td>
									<td>[[${train.emp.name}]]</td>
									<td>[[${train.dept.name}]]</td>
									<td>[[${#dates.format(train.trainDate, 'yyyy-MM-dd')}]]</td>
									<td>[[${#dates.format(train.trainEnd, 'yyyy-MM-dd')}]]</td>
									<td>[[${train.trainContent}]]</td>
									<td>[[${train.remark}]]</td>
									<td>
										<a class="btn btn-sm btn-primary" th:href="@{/train/}+${train.TId}">编辑</a>
										<button th:id="${train.TId}" th:attr="del_uri=@{/train/}+${train.TId}" class="btn btn-sm btn-danger deleteBtn">删除</button>
									</td>
								</tr>
							</tbody>
						</table>

						<div class="msg">
							<p th:text="${info}" th:if="${not #strings.isEmpty(info)}"></p>
						</div>
						<p class="info">
							当前第 <span th:text="${pageInfo.pageNum}"></span> 页,总共 <span
								th:text="${pageInfo.pages}"></span> 页,共 <span
								th:text="${pageInfo.total}"></span> 条记录
						</p>
						<ul class="pagination" th:if="${name}!=null">
							<li class="page-item"><a  class="page-link" th:if="${pageInfo.hasPreviousPage}" th:href="@{${url}(pageNum=${pageInfo.navigateFirstPage},name=${name},TWorkId=${TWorkId},deptname=${deptname})}">首页</a></li>
							<li class="page-item"><a  class="page-link" th:if="${pageInfo.hasPreviousPage}" th:href="@{${url}(pageNum=${pageInfo.prePage},name=${name},TWorkId=${TWorkId},deptname=${deptname})}">上一页</a></li>
							<li class="page-item"><a  class="page-link" th:if="${pageInfo.hasNextPage}" th:href="@{${url}(pageNum=${pageInfo.nextPage},name=${name},TWorkId=${TWorkId},deptname=${deptname})}">下一页</a></li>
							<li class="page-item"><a  class="page-link" th:if="${pageInfo.hasNextPage}" th:href="@{${url}(pageNum=${pageInfo.navigateLastPage},name=${name},TWorkId=${TWorkId},deptname=${deptname})}">末页</a></li>
						</ul>
						<ul class="pagination" th:if="${name}==null">
							<li class="page-item"><a class="page-link" th:href="@{/salarys}">首页</a></li>
							<li class="page-item"><a class="page-link"
													 th:href="@{${url}(pageNum=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}">上一页</a>
							</li>
							<li class="page-item"><a class="page-link"
													 th:href="@{${url}(pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}">下一页</a>
							</li>
							<li class="page-item"><a class="page-link" th:href="@{${url}(pageNum=${pageInfo.pages})}">尾页</a>
							</li>
						</ul>
					</div>
				</main>
				<form id="deleteEmptrainForm" method="post">
					<input type="hidden" name="_method" value="delete"/>
				</form>
			</div>
		</div>
		<script type="text/javascript" th:src="@{/webjars/jquery/3.5.0/jquery.js}"></script>
		<script>
			$(".deleteBtn").click(function(){
				var id = $(this).attr("id");
				if (confirm("确定要删除编号为"+id+"的培训数据吗?")){
					//删除当前数据
					$("#deleteEmptrainForm").attr("action",$(this).attr("del_uri")).submit();
					return true;
				}else {
					return false;
				}

            });
		</script>
	</body>
</html>